import os

from langchain_community.embeddings import OpenAIEmbeddings

# os.environ["OPENAI_API_KEY"] = 'sk-ce243630991443b2a32a217c15f8128c'
# os.environ["OPENAI_BASE_URL"] = 'https://dashscope.aliyuncs.com/compatible-mode/v1'
# from langchain.chat_models import ChatOpenAI
# chat = ChatOpenAI(model="deepseek-v3",
#                     temperature=0.8,
#                     max_tokens=60)
# from langchain.schema import (
#     HumanMessage,
#     SystemMessage
# )
# messages = [
#     SystemMessage(content="你是一个很棒的智能助手"),
#     HumanMessage(content="请给我的花店起个名")
# ]
# response = chat(messages)
# print(response)






# 初始化模型（默认使用 text-embedding-ada-002）
embeddings = OpenAIEmbeddings(
    model="text-embedding-v4",  # 可选模型
    api_key="sk-ce243630991443b2a32a217c15f8128c",
    base_url="https://dashscope.aliyuncs.com/compatible-mode/v1"
)

# 生成文本向量
texts = ["你好", "Hello world"]
vectors = embeddings.embed_documents(texts)  # 多文本
query_vector = embeddings.embed_query("你好吗")  # 单文本